import { z } from "zod";
import { TaskStatus } from '../type.js';
import { removeTask } from '../../../service/cron.js';
import { prisma } from '../../../service/mysql.js';

export default {
    api: "invalidTask",
    name: "禁用指定任务",
    description: "根据ID禁用任务，比如：禁用任务1。",
    requestSchema: z.object({
        id: z.number().describe("任务ID"),
    }),
    func: async ({ id }, context) => {
        const scheduleTask = await prisma.t_schedule_task.findFirst({
            where: {
                id: id
            }
        });
        if (!scheduleTask) {
            return `任务编号${id}不存在，无法执行禁用操作`;
        }
        
        await removeTask(id);
        return `任务禁用成功，编号为${scheduleTask.id}，任务内容为${scheduleTask.content}，请告知客户任务禁用的详情信息`;
    }
}